﻿using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.Design;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.ComponentModel;
using System.IO;

namespace Enterprise.Templates
{
    /// <summary>
    /// Loads an Template file with all controls
    /// </summary>
    [ToolboxData("<{0}:RegionPanel runat=\"server\"></{0}:RegionPanel>")]
    public class RegionPanel : WebControl, INamingContainer
    {
        private string _TemplateFile;

        public RegionPanel() { }

        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
        }


        /// <summary>
        /// The template file for this page.
        /// </summary>
        public string TemplateFile
        {
            get
            {
                return this._TemplateFile;
            }
            set
            {
                _TemplateFile = value;
            }
        }

        protected override void CreateChildControls()
        {
            //If no template is added, the default template file is loaded.
            //if (this._TemplateFile == null || this._TemplateFile == string.Empty)
              //  this._TemplateFile = "~/App_Data/Templates/Template.ascx";

            Control c = TemplateControl.LoadControl(this._TemplateFile);
            this.Controls.Add(c);
        }
    }
}
